package com.liveinstars.common;

import java.time.Period;

/**
 * Created by guoyanjiang on 2018/9/28.
 */
public class PeriodUtil {

    public static String formatPeriodToTimeCountDown(Period period) {
        int year = period.getYears();
        int month = period.getMonths();
        int day = period.getDays();
        if (year > 0) {
            return String.format("%d年%d个月后", year, month == 0 ? 1 : month);
        }
        if (month > 0) {
            return String.format("%d个月%d天后", month, day == 0 ? 1: day);
        }
        if (day > 0) {
            return String.format("%d天后", day);
        }
        return "今天";
    }

}
